<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   Spark Graphx:构建graph和聚合消息  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/7566.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466461182: Accept with keywords: (title(0.25):Spark,社区,消息,数盟, topn(0.366666666667):社区,定义,数盟,入口,行业资讯,阶段,数组,数据挖掘,发消息,遍历,分区,职业规划,基础架构,文章,可视化,Spark,排序,数据,属性,函数,对象,邻边,信息,集合,顶点,spark,路由表,编程语言,消息,数据结构).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    Spark Graphx:构建graph和聚合消息
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    Spark Graphx:构建graph和聚合消息 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,72] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/base">
       基础架构
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/7566.html">
          Spark Graphx:构建graph和聚合消息
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          4,551 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/base" rel="category tag">
          基础架构
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        作者：@玄畅
       </p>
       <h2>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#about" id="user-content-about">
        </a>
        About
       </h2>
       <p>
        最近在优化kcore算法时，对Graphx代码看了几遍。1.2后Graphx性能有所提升，代码不太容易理解，现在用图表示出来会更直观。
       </p>
       <p>
        对数学上的图有点印象的是x轴、y轴坐标图，坐标中每个点用横坐标x和纵坐标y表示，即: (x1, y1), (x2, y2), 一个坐标点可以确定一个点的唯一位置
       </p>
       <p>
        Graphx与上面的概念类似。不同的是, Graphx中的点概念更泛化，不一定用x y坐标表示，有唯一标示的对象即可，如：ID
       </p>
       <h2>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#1--%E6%9E%84%E5%BB%BAgraph" id="user-content-1--构建graph">
        </a>
        1. 构建Graph
       </h2>
       <p>
        graphx的
        <code>
         Graph
        </code>
        对象是用户操作图的入口, 它包含了边(edge)和顶点(vertices)两部分. 边由点组成，所以, 所有的边中包含的点的就是点的全集。但是这个全集包含重复的点, 去重复后就是VertexRDD
       </p>
       <p>
        点和边都包含一个attr属性，可以携带额外信息
       </p>
       <h3>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#11-%E6%9E%84%E5%BB%BA%E4%B8%80%E4%B8%AA%E5%9B%BE%E7%9A%84%E6%96%B9%E6%B3%95" id="user-content-11-构建一个图的方法">
        </a>
        1.1 构建一个图的方法
       </h3>
       <ol class="task-list">
        <li>
         根据边构建图(Graph.fromEdges)
         <br/>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686bfa94a08930045176" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            def fromEdges[VD: ClassTag, ED: ClassTag](
      edges: RDD[Edge[ED]],
      defaultValue: VD,
      edgeStorageLevel: StorageLevel = StorageLevel.MEMORY_ONLY,
      vertexStorageLevel: StorageLevel = StorageLevel.MEMORY_ONLY): Graph[VD, ED]
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-57686bfa94a08930045176-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a08930045176-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a08930045176-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a08930045176-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a08930045176-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a08930045176-6">
                 6
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-57686bfa94a08930045176-1">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-v">
                  fromEdges
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  VD
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  ClassTag
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  ED
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  ClassTag
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a08930045176-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  edges
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  RDD
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  Edge
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  ED
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a08930045176-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  defaultValue
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  VD
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a08930045176-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  edgeStorageLevel
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  StorageLevel
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  StorageLevel
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  MEMORY_ONLY
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a08930045176-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  vertexStorageLevel
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  StorageLevel
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  StorageLevel
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  MEMORY_ONLY
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  Graph
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  VD
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  ED
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a08930045176-6">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0027 seconds] -->
        </li>
        <li>
         根据边的两个点元数据构建(Graph.fromEdgeTuples)
         <br/>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686bfa94a19557178018" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            def fromEdgeTuples[VD: ClassTag](
  rawEdges: RDD[(VertexId, VertexId)],
  defaultValue: VD,
  uniqueEdges: Option[PartitionStrategy] = None,
  edgeStorageLevel: StorageLevel = StorageLevel.MEMORY_ONLY,
  vertexStorageLevel: StorageLevel = StorageLevel.MEMORY_ONLY): Graph[VD, Int] =
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-57686bfa94a19557178018-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a19557178018-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a19557178018-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a19557178018-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a19557178018-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a19557178018-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a19557178018-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a19557178018-8">
                 8
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-57686bfa94a19557178018-1">
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-v">
                  fromEdgeTuples
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  VD
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  ClassTag
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a19557178018-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  rawEdges
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  RDD
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  VertexId
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  VertexId
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a19557178018-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  defaultValue
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  VD
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a19557178018-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  uniqueEdges
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  Option
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  PartitionStrategy
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  None
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a19557178018-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  edgeStorageLevel
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  StorageLevel
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  StorageLevel
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  MEMORY_ONLY
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a19557178018-6">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  vertexStorageLevel
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  StorageLevel
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  StorageLevel
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  MEMORY_ONLY
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  Graph
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  VD
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-t">
                  Int
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a19557178018-7">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a19557178018-8">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0029 seconds] -->
        </li>
       </ol>
       <h3>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#12-%E7%AC%AC%E4%B8%80%E6%AD%A5%E6%9E%84%E5%BB%BA%E8%BE%B9edgerdd" id="user-content-12-第一步构建边edgerdd">
        </a>
        1.2 第一步：构建边EdgeRDD
       </h3>
       <p>
        (点击查看大图)
        <br/>
        <a href="https://github.com/shijinkui/spark_study/blob/master/img/graphx_build_edge.jpg" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/graphx_build_edge1.jpg"/>
        </a>
       </p>
       <h4>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#121-%E5%8A%A0%E8%BD%BD%E8%BE%B9%E7%9A%84%E6%96%87%E6%9C%AC%E4%BF%A1%E6%81%AF" id="user-content-121-加载边的文本信息">
        </a>
        1.2.1 加载边的文本信息
       </h4>
       <p>
        从持久化系统（HDFS）中加载边的文本信息，按行处理生成tuple, 即
        <code>
         (srcId, dstId)
        </code>
       </p>
       <p>
        api：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686bfa94a21433468851" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          val rawEdgesRdd: RDD[(Long, Long)] = sc.textFile(input, partitionNum).filter(s =&amp;gt; s != "0,0").repartition(partitionNum).map {
      case line =&amp;gt;
        val ss = line.split(",")
        val src = ss(0).toLong
        val dst = ss(1).toLong
        if (src &amp;lt; dst)
          (src, dst)
        else
          (dst, src)
    }.distinct()
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686bfa94a21433468851-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a21433468851-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a21433468851-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a21433468851-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a21433468851-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a21433468851-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a21433468851-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a21433468851-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a21433468851-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a21433468851-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a21433468851-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a21433468851-12">
               12
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686bfa94a21433468851-1">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                val
               </span>
               <span class="crayon-v">
                rawEdgesRdd
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                RDD
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-t">
                Long
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                Long
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sc
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                textFile
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                input
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                partitionNum
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                filter
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                s
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =&amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                s
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                !=
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "0,0"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                repartition
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                partitionNum
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-i">
                map
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a21433468851-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                case
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                line
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =&amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a21433468851-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                val
               </span>
               <span class="crayon-v">
                ss
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                line
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                split
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                ","
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a21433468851-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                val
               </span>
               <span class="crayon-v">
                src
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                ss
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                toLong
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a21433468851-5">
               <span class="crayon-e">
               </span>
               <span class="crayon-e">
                val
               </span>
               <span class="crayon-v">
                dst
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                ss
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                toLong
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a21433468851-6">
               <span class="crayon-e">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                src
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                dst
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a21433468851-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                src
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                dst
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a21433468851-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                else
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a21433468851-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                dst
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                src
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a21433468851-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                distinct
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a21433468851-11">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a21433468851-12">
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0043 seconds] -->
       <p>
        数据形如：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686bfa94a28832663068" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          107,109
108,109
110,111
110,112
111,112
113,114
115,116
117,79
117,118
79,118
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686bfa94a28832663068-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a28832663068-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a28832663068-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a28832663068-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a28832663068-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a28832663068-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a28832663068-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a28832663068-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a28832663068-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a28832663068-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a28832663068-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a28832663068-12">
               12
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686bfa94a28832663068-1">
               <span class="crayon-cn">
                107
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                109
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a28832663068-2">
               <span class="crayon-cn">
                108
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                109
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a28832663068-3">
               <span class="crayon-cn">
                110
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                111
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a28832663068-4">
               <span class="crayon-cn">
                110
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                112
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a28832663068-5">
               <span class="crayon-cn">
                111
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                112
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a28832663068-6">
               <span class="crayon-cn">
                113
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                114
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a28832663068-7">
               <span class="crayon-cn">
                115
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                116
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a28832663068-8">
               <span class="crayon-cn">
                117
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                79
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a28832663068-9">
               <span class="crayon-cn">
                117
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                118
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a28832663068-10">
               <span class="crayon-cn">
                79
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                118
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a28832663068-11">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a28832663068-12">
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0013 seconds] -->
       <p>
       </p>
       <h4>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#122-------%E7%AC%AC%E4%BA%8C%E6%AD%A5%E5%88%9D%E6%AD%A5%E7%94%9F%E6%88%90graph" id="user-content-122-------第二步初步生成graph">
        </a>
        1.2.2 第二步：初步生成Graph
       </h4>
       <ol class="task-list">
        <li>
         入口：
         <code>
          Graph.fromEdgeTuples(rawEdgesRdd)
         </code>
         <br/>
         元数据为
         <code>
          ,
         </code>
         分割的两个点ID，把元数据映射成
         <code>
          Edge(srcId, dstId, attr)
         </code>
         对象, attr默认为null。这样元数据就构建成了
         <code>
          RDD[Edge[ED]]
         </code>
        </li>
        <li>
         <code>
          RDD[Edge[ED]]
         </code>
         要进一步转化成
         <code>
          EdgeRDDImpl[ED, VD]
         </code>
         <br/>
         首先遍历
         <code>
          RDD[Edge[ED]]
         </code>
         的分区
         <code>
          partitions
         </code>
         ，对分区内的边重排序
         <code>
          new Sorter(Edge.edgeArraySortDataFormat[ED]).sort(edgeArray, 0, edgeArray.length, Edge.lexicographicOrdering)
         </code>
         即：按照srcId从小到大排序。
         <p>
         </p>
         <p>
          问：为何要重排序？
          <br/>
          答：为了遍历时顺序访问。采用数组而不是Map，数组是连续的内存单元，具有原子性，避免了Map的hash问题，访问速度快
         </p>
        </li>
        <li>
         填充localSrcIds,localDstIds, data, index, global2local, local2global, vertexAttrs
         <p>
          数组localSrcIds,localDstIds中保存的是经过
          <code>
           global2local.changeValue(srcId/dstId)
          </code>
          转变的本地索引，即：
          <code>
           localSrcIds
          </code>
          、
          <code>
           localDstIds
          </code>
          数组下标对应于分区元素，数组中保存的索引位可以定位到
          <code>
           local2global
          </code>
          中查到具体的VertexId
         </p>
         <p>
          <code>
           global2local
          </code>
          是spark私有的Map数据结构
          <code>
           GraphXPrimitiveKeyOpenHashMap
          </code>
          , 保存vertextId和本地索引的映射关系。
          <code>
           global2local
          </code>
          中包含当前partition所有srcId、dstId与本地索引的映射关系。
         </p>
         <p>
          <code>
           data
          </code>
          就是当前分区的attr属性数组
         </p>
         <p>
          <code>
           index
          </code>
          索引最有意思，按照srcId重排序的边数据, 会看到相同的srcId对应了不同的
          <code>
           dstId
          </code>
          , 见图中
          <code>
           index desc
          </code>
          部分。
          <code>
           index
          </code>
          中记录的是
          <strong>
           相同
           <code>
            srcId
           </code>
           中第一个出现的
           <code>
            srcId
           </code>
           与其下标
          </strong>
          。
         </p>
         <p>
          <code>
           local2global
          </code>
          记录的是所有的VertexId信息的数组。形如：
          <code>
           srcId,dstId,srcId,dstId,srcId,dstId,srcId,dstId
          </code>
          。其中会包含相同的ID。即：当前分区所有vertextId的顺序实际值
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686bfa94a31720692116" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            ＃ 用途：
＃ 根据本地下标取VertexId
localSrcIds/localDstIds -&amp;gt; index -&amp;gt; local2global -&amp;gt; VertexId

＃ 根据VertexId取本地下标，取属性
VertexId -&amp;gt; global2local -&amp;gt; index -&amp;gt; data -&amp;gt; attr object
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-57686bfa94a31720692116-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a31720692116-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a31720692116-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a31720692116-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a31720692116-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a31720692116-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a31720692116-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a31720692116-8">
                 8
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-57686bfa94a31720692116-1">
                 ＃
                 <span class="crayon-h">
                 </span>
                 用途：
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a31720692116-2">
                 ＃
                 <span class="crayon-h">
                 </span>
                 根据本地下标取
                 <span class="crayon-e">
                  VertexId
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a31720692116-3">
                 <span class="crayon-v">
                  localSrcIds
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  localDstIds
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  index
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  local2global
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  VertexId
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a31720692116-4">
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a31720692116-5">
                 ＃
                 <span class="crayon-h">
                 </span>
                 根据
                 <span class="crayon-i">
                  VertexId
                 </span>
                 取本地下标，取属性
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a31720692116-6">
                 <span class="crayon-v">
                  VertexId
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  global2local
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  index
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  data
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  attr
                 </span>
                 <span class="crayon-t">
                  object
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a31720692116-7">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a31720692116-8">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0025 seconds] -->
         <p>
          <em>
           spark的数据最终是在patition中表达，所以各种transform都在这里进行，这里的数据结构性能至关重要
          </em>
         </p>
        </li>
       </ol>
       <h3>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#13-%E7%AC%AC%E4%BA%8C%E6%AD%A5%E6%9E%84%E5%BB%BA%E9%A1%B6%E7%82%B9vertexrdd" id="user-content-13-第二步构建顶点vertexrdd">
        </a>
        1.3 第二步：构建顶点(VertexRDD)
       </h3>
       <p>
        (点击查看大图)
        <br/>
        <a href="https://github.com/shijinkui/spark_study/blob/master/img/graphx_build_vertex.jpg" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/graphx_build_vertex.jpg"/>
        </a>
       </p>
       <p>
        入口：
        <code>
         GraphImpl
        </code>
        365行。
        <code>
         val vertices = VertexRDD.fromEdges(edgesCached, edgesCached.partitions.size, defaultVertexAttr).withTargetStorageLevel(vertexStorageLevel)
        </code>
       </p>
       <p>
        根据边
        <code>
         EdgeRDD[ED, VD]
        </code>
        构建出点
        <code>
         VertexRDD
        </code>
        , 点是孤岛，不像边一样保存点与点之间的关系。点只保存属性attr。所以需要对拿到的点做分区。
       </p>
       <p>
        为了能通过点找到边，每个点需要保存点所在到边信息即分区Id(pid)，这些新保存在路由表
        <code>
         RoutingTablePartition
        </code>
        中。
       </p>
       <p>
        <strong>
         构建的过程：
        </strong>
       </p>
       <ol class="task-list">
        <li>
         创建路由表
         <p>
          根据
          <code>
           EdgeRDD
          </code>
          ，map其分区，对edge partition中的数据转换成
          <code>
           RoutingTableMessage
          </code>
          数据结构。
         </p>
         <p>
          <strong>
           特别激动的是:
          </strong>
          为节省内存，把edgePartitionId和一个标志位通过一个32位的
          <code>
           int
          </code>
          表示。
         </p>
         <p>
          如图所示，
          <code>
           RoutingTableMessage
          </code>
          是自定义的类型类, 一个包含vid和int的tuple
          <code>
           (VertexId, Int)
          </code>
          。 int的32~31位表示一个标志位,
          <code>
           01: isSrcId 10: isDstId
          </code>
          。30～0位表示边分区ID。赞这种做法，目测作者是山西人。
         </p>
         <p>
          <code>
           RoutingTableMessage
          </code>
          想表达这样的信息：一个顶点ID，不管未来你到天涯海角，请带着你女朋友
          <code>
           Edge
          </code>
          的地址: edge分区ID。并且带着一个标志你在女友心中的位置是：
          <code>
           01
          </code>
          是左边
          <code>
           isSrcId
          </code>
          ，
          <code>
           10
          </code>
          是右边
          <code>
           isDstId
          </code>
          。这样就算你流浪到非洲，也能找到小女友约会…blabla…
         </p>
        </li>
        <li>
         根据路由表生成分区对象
         <code>
          vertexPartitions
         </code>
         <ol class="task-list">
          <li>
           上（1）中生成的消息路由表信息，重新分区，分区数目根edge分区数保持一致。
          </li>
          <li>
           在新分区中，map分区中的每条数据，从
           <code>
            RoutingTableMessage
           </code>
           解出数据：vid, edge pid, isSrcId/isDstId。这个三个数据项重新封装到三个数据结构中:pid2vid,srcFlags,dstFlags
          </li>
          <li>
           <strong>
            有意思的地方来了
           </strong>
           ，想一下，shuffle以后新分区中的点来自于之前edge不同分区，那么一个点要找到边，就需要先确定边的分区号pid, 然后在确定的edge分区中确定是srcId还是dstId, 这样就找到了边。
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686bfa94a3a202800624" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              val pid2vid = Array.fill(numEdgePartitions)(new PrimitiveVector[VertexId])
val srcFlags = Array.fill(numEdgePartitions)(new PrimitiveVector[Boolean])
val dstFlags = Array.fill(numEdgePartitions)(new PrimitiveVector[Boolean])
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-57686bfa94a3a202800624-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a3a202800624-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-57686bfa94a3a202800624-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a3a202800624-4">
                   4
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-57686bfa94a3a202800624-1">
                   <span class="crayon-e">
                    val
                   </span>
                   <span class="crayon-v">
                    pid2vid
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    Array
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    fill
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    numEdgePartitions
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    PrimitiveVector
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    VertexId
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a3a202800624-2">
                   <span class="crayon-e">
                    val
                   </span>
                   <span class="crayon-v">
                    srcFlags
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    Array
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    fill
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    numEdgePartitions
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    PrimitiveVector
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-t">
                    Boolean
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686bfa94a3a202800624-3">
                   <span class="crayon-e">
                    val
                   </span>
                   <span class="crayon-v">
                    dstFlags
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    Array
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    fill
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    numEdgePartitions
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    PrimitiveVector
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-t">
                    Boolean
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a3a202800624-4">
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0022 seconds] -->
           <p>
            上面表达的是：当前vertex分区中点在edge分区中的分布。新分区中保存这样的记录
            <code>
             (vids.trim().array, toBitSet(srcFlags(pid)), toBitSet(dstFlags(pid)))
            </code>
            vid, srcFlag, dstFlag, flag通过
            <code>
             BitSet
            </code>
            存储，很省。
           </p>
           <p>
            如此就生成了vertex的路由表
            <code>
             routingTables
            </code>
           </p>
          </li>
          <li>
           生成ShippableVertexPartition
           <p>
            根据上面
            <code>
             routingTables
            </code>
            , 重新封装路由表里的数据结构为：
            <code>
             ShippableVertexPartition
            </code>
           </p>
           <p>
            ShippableVertexPartition会合并相同重复点的属性attr对象，补全缺失的attr对象。
           </p>
           <p>
            关键是：根据vertexId生成
            <code>
             map:GraphXPrimitiveKeyOpenHashMap
            </code>
            ，这个map跟边中的
            <code>
             global2local
            </code>
            是不是很相似？这个map根据long vertxId生成下标索引，目测：相同的点会有相同的下标。// todo..
           </p>
          </li>
         </ol>
        </li>
        <li>
         创建
         <code>
          VertexRDDImpl
         </code>
         对象
         <br/>
         <code>
          new VertexRDDImpl(vertexPartitions)
         </code>
         ，这就完事了
        </li>
       </ol>
       <h3>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#14-%E7%AC%AC%E4%B8%89%E6%AD%A5----%E7%94%9F%E6%88%90graph%E5%AF%B9%E8%B1%A1finished" id="user-content-14-第三步----生成graph对象finished">
        </a>
        1.4 第三步 生成Graph对象［finished］
       </h3>
       <p>
        (点击查看大图)
        <br/>
        <a href="https://github.com/shijinkui/spark_study/blob/master/img/graphx_build_graph.jpg" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/graphx_build_graph.jpg"/>
        </a>
       </p>
       <p>
        把上述edgeRDD和vertexRDD拿过来组成Graph
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686bfa94a42559672143" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          new GraphImpl(vertices, new ReplicatedVertexView(edges.asInstanceOf[EdgeRDDImpl[ED, VD]]))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686bfa94a42559672143-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a42559672143-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a42559672143-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686bfa94a42559672143-1">
               <span class="crayon-r">
                new
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                GraphImpl
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                vertices
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                new
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                ReplicatedVertexView
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                edges
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                asInstanceOf
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                EdgeRDDImpl
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                ED
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                VD
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a42559672143-2">
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a42559672143-3">
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0011 seconds] -->
       <p>
       </p>
       <h2>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#2-%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0%E5%88%86%E6%9E%90" id="user-content-2-常用函数分析">
        </a>
        2. 常用函数分析
       </h2>
       <p>
        下面分析一下常用的graph函数
        <code>
         aggregateMessages
        </code>
       </p>
       <h3>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#21--aggregatemessages" id="user-content-21--aggregatemessages">
        </a>
        2.1 aggregateMessages
       </h3>
       <p>
        <code>
         aggregateMessages
        </code>
        是Graphx最重要的API，1.2版本添加的新函数，用于替换
        <code>
         mapReduceTriplets
        </code>
        。目前
        <code>
         mapReduceTriplets
        </code>
        最终也是使用兼容的
        <code>
         aggregateMessages
        </code>
       </p>
       <p>
        据说改用
        <code>
         aggregateMessages
        </code>
        后，性能提升30%。
       </p>
       <p>
        它主要功能是向邻边发消息，合并邻边收到的消息，返回messageRDD
       </p>
       <p>
        aggregateMessages的接口如下：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686bfa94a4a089522954" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          def aggregateMessages[A: ClassTag](
      sendMsg: EdgeContext[VD, ED, A] =&amp;gt; Unit,
      mergeMsg: (A, A) =&amp;gt; A,
      tripletFields: TripletFields = TripletFields.All)
    : VertexRDD[A] = {
    aggregateMessagesWithActiveSet(sendMsg, mergeMsg, tripletFields, None)
  }
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686bfa94a4a089522954-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a4a089522954-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a4a089522954-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a4a089522954-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a4a089522954-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a4a089522954-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a4a089522954-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a4a089522954-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57686bfa94a4a089522954-9">
               9
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686bfa94a4a089522954-1">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                def
               </span>
               <span class="crayon-v">
                aggregateMessages
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                A
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ClassTag
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                (
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a4a089522954-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sendMsg
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                EdgeContext
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                VD
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ED
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                A
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =&amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                Unit
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a4a089522954-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mergeMsg
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                A
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                A
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =&amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                A
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a4a089522954-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tripletFields
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                TripletFields
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                TripletFields
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                All
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a4a089522954-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                VertexRDD
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                A
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a4a089522954-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                aggregateMessagesWithActiveSet
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                sendMsg
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mergeMsg
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tripletFields
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                None
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a4a089522954-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a4a089522954-8">
              </div>
              <div class="crayon-line" id="crayon-57686bfa94a4a089522954-9">
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0032 seconds] -->
       <p>
       </p>
       <ul class="task-list">
        <li>
         sendMsg： 发消息函数
         <br/>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686bfa94a50468936742" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            private def sendMsg(ctx: EdgeContext[KCoreVertex, Int, Map[Int, Int]]): Unit = {
    ctx.sendToDst(Map(ctx.srcAttr.preKCore -&amp;gt; -1, ctx.srcAttr.curKCore -&amp;gt; 1))
    ctx.sendToSrc(Map(ctx.dstAttr.preKCore -&amp;gt; -1, ctx.dstAttr.curKCore -&amp;gt; 1))
}
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-57686bfa94a50468936742-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a50468936742-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a50468936742-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a50468936742-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a50468936742-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a50468936742-6">
                 6
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-57686bfa94a50468936742-1">
                 <span class="crayon-m">
                  private
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  sendMsg
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  ctx
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  EdgeContext
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  KCoreVertex
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-t">
                  Int
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  Map
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-t">
                  Int
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-t">
                  Int
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  Unit
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  {
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a50468936742-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  ctx
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  sendToDst
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-e">
                  Map
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  ctx
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  srcAttr
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  preKCore
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  ctx
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  srcAttr
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  curKCore
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a50468936742-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  ctx
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  sendToSrc
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-e">
                  Map
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  ctx
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  dstAttr
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  preKCore
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  ctx
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  dstAttr
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  curKCore
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a50468936742-4">
                 <span class="crayon-sy">
                  }
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a50468936742-5">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a50468936742-6">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0037 seconds] -->
        </li>
        <li>
         mergeMsg：合并消息函数。用于Map阶段，每个edge分区中每个点收到的消息合并，以及reduce阶段，合并不同分区的消息。合并vertexId相同的消息
        </li>
        <li>
         tripletFields：定义发消息的方向
        </li>
       </ul>
       <h4>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#211-------aggregatemessages---map%E9%98%B6%E6%AE%B5" id="user-content-211-------aggregatemessages---map阶段">
        </a>
        2.1.1 aggregateMessages Map阶段
       </h4>
       <p>
        (点击查看大图)
        <br/>
        <a href="https://github.com/shijinkui/spark_study/blob/master/img/graphx_aggmsg_map.jpg" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/graphx_aggmsg_map.jpg"/>
        </a>
       </p>
       <p>
        从入口函数进入aggregateMessagesWithActiveSet，首先使用
        <code>
         VertexRDD[VD]
        </code>
        更新
        <code>
         replicatedVertexView
        </code>
        , 只更新其中vertexRDD中attr对象。
       </p>
       <p>
        问：为啥更新replicatedVertexView？ 答：replicatedVertexView就是个点和边的视图，点的属性有变化，要更新边中包含的点的attr
       </p>
       <p>
        <code>
         replicatedVertexView
        </code>
        这里对edgeRDD做
        <code>
         mapPartitions
        </code>
        操作，所有的操作都在每个边分区的迭代中完成。
       </p>
       <ol class="task-list">
        <li>
         进入aggregateMessagesEdgeScan
         <p>
          前文中提到edge partition中包含的五个重要数据结构之一：
          <code>
           localSrcIds
          </code>
          , 顶点vertixId在当前分区中的索引.
         </p>
         <ol class="task-list">
          <li>
           遍历
           <code>
            localSrcIds
           </code>
           , 根据其下标去
           <code>
            localSrcIds
           </code>
           中拿到srcId在全局
           <code>
            local2global
           </code>
           中的索引位，然后拿到srcId； 同理，根据下标，去
           <code>
            localDstIds
           </code>
           中取到
           <code>
            local2global
           </code>
           中的索引位, 取出dstId
          </li>
         </ol>
         <p>
          有了srcId和dstId，你就可以blabla….
         </p>
         <p>
          问： 为啥用
          <code>
           localSrcIds
          </code>
          的下标
          <br/>
          答： 用
          <code>
           localDstIds
          </code>
          的也可以。一条边必然包含两个点:srcId, dstId
         </p>
         <ol class="task-list">
          <li>
           发消息
           <p>
            看上图:
           </p>
           <ul class="task-list">
            <li>
             根据接口中定义的tripletFields，拿到发消息的方向: 1) 向dstId发；2) 向srcId发；3) 向两边发；4) 向其中一边发
            </li>
            <li>
             发消息的过程就是遍历到一条边，向以srcId/dstId在本分区内的本地ID
             <code>
              localId
             </code>
             为下标的数组中添加数据，如果
             <code>
              localId
             </code>
             为下标数组中已经存在数据，则执行合并函数
             <code>
              mergeMsg
             </code>
            </li>
            <li>
             每个点之间在发消息的时候是独立的，即：点单纯根据方向，向以相邻点的
             <code>
              localId
             </code>
             为下标的数组中插数据，互相独立，在并行上互不影响。
             <br/>
             完事，返回消息RDD
             <code>
              messages: RDD[(VertexId, VD2)]
             </code>
            </li>
           </ul>
          </li>
         </ol>
        </li>
       </ol>
       <h4>
        <a class="anchor" href="https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown#212-------aggregatemessages---reduce%E9%98%B6%E6%AE%B5" id="user-content-212-------aggregatemessages---reduce阶段">
        </a>
        2.1.2 aggregateMessages Reduce阶段
       </h4>
       <p>
        (点击查看大图)
        <a href="https://github.com/shijinkui/spark_study/blob/master/img/graphx_aggmsg_reduce.jpg" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/graphx_aggmsg_reduce.jpg"/>
        </a>
       </p>
       <p>
        因为对边上，对点发消息，所以在reduce阶段主要是
        <code>
         VertexRDD
        </code>
        的菜。
       </p>
       <p>
        入口(Graphmpl 260行)：
        <code>
         vertices.aggregateUsingIndex(preAgg, mergeMsg)
        </code>
       </p>
       <p>
        收到
        <code>
         messages: RDD[(VertexId, VD2)]
        </code>
        消息RDD，开始：
       </p>
       <ol class="task-list">
        <li>
         对
         <code>
          messages
         </code>
         做shuffled分区，分区器使用VertexRDD的
         <code>
          partitioner
         </code>
         。
         <p>
          因为VertexRDD的partitioner根据点VertexID做分区，所以
          <code>
           vertexId-&gt;消息
          </code>
          分区后的pid根VertextRDD完全相同，这样用zipPartitions高效的合并两个分区的数据
         </p>
        </li>
        <li>
         根据对等合并attr, 聚合函数使用API传入的
         <code>
          mergeMsg
         </code>
         函数
         <ul class="task-list">
          <li>
           小技巧：遍历节点时，遍历messagePartition。并不是每个节点都会收到消息，所以
           <code>
            messagePartition
           </code>
           集合最小，所以速度会快。遍历小集合取大集合的数据。
          </li>
          <li>
           前文提到根据routingTables路由表生成VertexRDD的vertexPartitions时, vertexPartitions中重新封装了ShippableVertexPartition对象，其定义为：
          </li>
         </ul>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686bfa94a5b041462322" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            ShippableVertexPartition[VD: ClassTag](
val index: VertexIdToIndexMap,
val values: Array[VD],
val mask: BitSet,
val routingTable: RoutingTablePartition)
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-57686bfa94a5b041462322-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a5b041462322-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a5b041462322-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a5b041462322-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-57686bfa94a5b041462322-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-57686bfa94a5b041462322-6">
                 6
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-57686bfa94a5b041462322-1">
                 <span class="crayon-v">
                  ShippableVertexPartition
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  VD
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  ClassTag
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a5b041462322-2">
                 <span class="crayon-e">
                  val
                 </span>
                 <span class="crayon-v">
                  index
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  VertexIdToIndexMap
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a5b041462322-3">
                 <span class="crayon-e">
                  val
                 </span>
                 <span class="crayon-v">
                  values
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-t">
                  Array
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  VD
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a5b041462322-4">
                 <span class="crayon-e">
                  val
                 </span>
                 <span class="crayon-v">
                  mask
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  BitSet
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line" id="crayon-57686bfa94a5b041462322-5">
                 <span class="crayon-e">
                  val
                 </span>
                 <span class="crayon-v">
                  routingTable
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  RoutingTablePartition
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-57686bfa94a5b041462322-6">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0015 seconds] -->
         <p>
          最后生成对象：
          <code>
           new ShippableVertexPartition(map.keySet, map._values, map.keySet.getBitSet, routingTable)
          </code>
         </p>
         <p>
          所以这里用到的
          <code>
           index
          </code>
          就是map.keySet, map就是映射
          <code>
           vertexId-&gt;attr
          </code>
         </p>
         <p>
          index: map.keySet, hashSet, vertexId-&gt;下标
         </p>
         <p>
          values: map._valuers, Array[Int], 根据下标保存attr。
         </p>
         <p>
          so so，根据vetexId从index中取到其下标，再根据下标，从values中取到attr，存在attr就用API传入的函数
          <code>
           mergeMsg
          </code>
          合并属性attr; 不存在就直接赋值。
         </p>
        </li>
       </ol>
       <p>
        最后得到的是收到消息的
        <code>
         VertexRDD
        </code>
       </p>
       <p>
        到这里，整个map/reduce过程就完成了。
       </p>
       <hr/>
       <p>
        翠花，上全图
       </p>
       <p>
        (点击查看大图)
        <a href="https://github.com/shijinkui/spark_study/blob/master/img/graphx_global.jpg" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/graphx_global1.jpg"/>
        </a>
       </p>
       <p>
        <em>
         如果没有绕晕，从头再读一遍
        </em>
       </p>
       <p>
        ——待续——–
       </p>
       <p>
       </p>
       <p>
        文章出处：https://github.com/shijinkui/spark_study/blob/master/spark_graphx_analyze.markdown
       </p>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/24670.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/20141222134630106-300x164.png"/>
        </a>
        <a class="link" href="http://dataunion.org/24670.html" rel="bookmark" title="Apache Spark 不过时的六大理由">
         Apache Spark 不过时的六大理由
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24558.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/wKiom1dcvqDBYzojAAF3j3hfL_s877.jpg-wh_651x-s_1673119543-300x197.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24558.html" rel="bookmark" title="实现R与Hadoop联合作业的三种方法">
         实现R与Hadoop联合作业的三种方法
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24454.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/234040u557x77z325w2g3o-267x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24454.html" rel="bookmark" title="LinkedIn 开源其分布式对象存储系统 Ambry">
         LinkedIn 开源其分布式对象存储系统 Ambry
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24349.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/05/20150402110749389-249x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24349.html" rel="bookmark" title="生活处处皆学问，我从星巴克咖啡学到的5点架构经验">
         生活处处皆学问，我从星巴克咖啡学到的5点架构经验
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F7566.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/7566.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/7566.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>